home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / ucb_logo / logo.doc < prev    next >
Encoding:
Text File  |  1996-07-16  |  32.6 KB  |  711 lines

  1.        Introduction.  Logo is  a  computer  programming  language  which  was
  2.   designed  to be both simple to use and extremely powerful.  It was designed
  3.   by a group of computer scientists at MIT and at Bolt, Beranek, and  Newman.
  4.   Its  structure  is based largely on the LISP language, which is widely used
  5.   in Artificial Intelligence research, but the notation has been  changed  to
  6.   make  Logo  far  easier  for a beginner than LISP.
  7.  
  8.        The power of Logo comes primarily from the idea of the  procedure.   A
  9.   procedure  is  simply  something  the computer "knows" how to do; some pro-
  10.   cedures are built into Logo itself (these are called primitive procedures),
  11.   while  others  are  defined by the programmer in terms of these simple pro-
  12.   cedures.  Defined procedures can be used as part of the definition of other
  13.   procedures,  so that a complicated program can be built in "layers" of com-
  14.   plexity.  This layered structure is analogous to the description of a  com-
  15.   plex  machine  in  terms  of  building  blocks:  an automobile is made of a
  16.   chassis, a drive train, an electrical system, and so on.  The  drive  train
  17.   contains  an  engine,  a  transmission,  a clutch, an axle, and so on.  The
  18.   transmission contains a housing, gears, and levers.  A  lever  may  include
  19.   connecting  joints  at  the  ends  and  at  a  pivot point.  Eventually the
  20.   description of the automobile reaches the level of bolts and washers; these
  21.   correspond to the primitive procedures in Logo.
  22.  
  23.        Starting_Logo.  Start the Logo interpreter from  WorkBench or from the
  24.   CLI.   When Logo is  running it will print a  question mark (?)  at the be-
  25.   ginning of a line to indicate that it is ready for you to type  in  a  Logo
  26.   instruction.   The instruction may print something on the terminal, or draw
  27.   a line on a graphics display screen.  Then  another  question mark is typed
  28.   and you may give another instruction. (If Logo prints a "greater than" sign
  29.   (>) instead  of  a  question  mark,  it  is  in  list  input  mode,  which
  30.   will be  described later.  Type your  system quit  character (control-G) to
  31.   return to normal mode.)
  32.  
  33.        Syntax.  Unlike most computer languages, Logo has an  almost  entirely
  34.   uniform  syntax.   That  is, all of the different commands Logo understands
  35.   are represented using the same notation: the name of a  procedure  is  fol-
  36.   lowed  by  its inputs, which may be constants (like numbers) or else may be
  37.   the results of using other procedures.  Here is a simple example:
  38.  
  39.        print "hello
  40.  
  41.   In this Logo instruction, the primitive procedure print is used with a con-
  42.   stant  input,  the  word hello.  The quotation mark indicates that hello is
  43.   being used to represent the word itself;  without  the  quotation  mark  it
  44.   would  have  been  interpreted as the name of a procedure, just as print is
  45.   the name of a procedure.   In Logo, the print  procedure requires at  least
  46.   one input,  which is the thing  to print.   The input can be a word,  as in
  47.   this example,  or a list,  which will be explained later.   (A number  is a
  48.   special  case of a word, and a sentence is a special case of a list.)  Here
  49.   is another example:
  50.  
  51.        print first "hello
  52.  
  53.   Here, the primitive procedure first is being used, also.  It has one input,
  54.   a word,  and has an output which is the first letter of the word.  The out-
  55.   put from first  is used as the  input to print,  so what is  printed is the
  56.   letter h rather than the word hello as in the earlier example.
  57.  
  58.        Don't confuse the output from a procedure with what is printed by  the
  59.   print  command.  In Logo, the word "output" is not used to refer to what is
  60.   printed by a program, just as the word "input" does not mean something  you
  61.   type  into  the  program.   Instead, these words refer to objects (words or
  62.   lists) which are given to a procedure (inputs) or produced by  a  procedure
  63.   (outputs).  A particular procedure will have a fixed number (possibly zero)
  64.   of required inputs,  and may have optional inputs.   It may or may not pro-
  65.   duce an output.  A procedure with an output (like first) is called an oper-
  66.   ation; one without an output (like print) is called a command.
  67.  
  68.        Some operations only have two possible outputs: the word TRUE and  the
  69.   word  FALSE.   Such a procedure is called a predicate.  Predicates are used
  70.   to allow a program to carry out some instruction only if a particular  con-
  71.   dition  is met.  By convention, predicates generally have names ending with
  72.   the letter "p".
  73.  
  74.        Multiple_inputs_to_operations.  Several Logo primitive procedures  are
  75.   operations with two inputs.  The arithmetic operations, like sum, are exam-
  76.   ples of this.  A special extension to Logo syntax allows such an  operation
  77.   to  have  more than two inputs by enclosing the operation and its inputs in
  78.   parentheses:
  79.  
  80.        ( sum 2 5 13 8.5 )
  81.  
  82.        Multi-instruction_lines.  It is possible to put more than one instruc-
  83.   tion on the same line when you are typing to Logo.  For example,
  84.  
  85.        print "hello print "goodbye
  86.  
  87.   Later in this manual,  the phrase "instruction line"  will mean one or more
  88.   instructions on a line.
  89.  
  90.        Multi-line_instructions. It is possible to continue an instruction  on
  91.   a second line.  At the end of the first line, close with a tilde (~) to let
  92.   Logo know you want to continue:
  93.  
  94.        repeat 5 [ print ~
  95.           "Greetings! ]
  96.  
  97.   Here, Greetings! will be printed five times.
  98.  
  99.        Comments.  It is possible to include comments  in an instruction  line
  100.   which are meant for human readers of your program (including yourself, next
  101.   week), and which are not Logo instructions.  To do this, begin the  comment
  102.   with  an  semi-colon ";".  Everything after the semi-colon on the line will
  103.   be ignored by Logo.  For example:
  104.  
  105.        print [ Hi, there. ]     ; A friendly greeting.
  106.  
  107.   However, the semi-colon does not begin a comment if it is part of a word or
  108.   list (see below).   You must type a space  before the semi-colon  (if it is
  109.   not at the beginning of a line) and after it,  as in the example above,  to
  110.   make sure it will be interpreted as the beginning of a comment.
  111.  
  112.        Words.  Every computer language deals with  particular  kinds  of  ob-
  113.   jects.   Most languages, like FORTRAN or BASIC or Pascal, are best at deal-
  114.   ing with numbers.  Logo is a list processing language, which is at its best
  115.   with  more  complicated data structures.  The two main categories of object
  116.   are the word and the list.
  117.  
  118.        A word is a string of characters.   A character is  a  letter,  digit,
  119.   space, or punctuation mark.  A word can be any length, including zero.  The
  120.   way to indicate a word  as part of a Logo program  is to use the  quotation
  121.   mark (")  before the word.   The word begins  with the character  after the
  122.   quotation mark and continues until a space,  or the end of the line occurs.
  123.   A quotation  mark immediately  followed by a space or RETURN  indicates the
  124.   empty word, which is a word of length zero.
  125.  
  126.        Please notice that, unlike most programming languages, Logo  does  not
  127.   use quotation marks in pairs to delimit strings of characters.  The follow-
  128.   ing instruction is incorrect:
  129.  
  130.        print "aardvark"
  131.  
  132.   It will print `aardvark"'; not `aardvark'.
  133.  
  134.        In order to  include  a space in  a word,  you must  precede it with a
  135.   backslash (\).  Do not confuse  backslash with the  regular slash (/) char-
  136.   acter.  For example, this instruction:
  137.  
  138.        print "Hello\ there
  139.  
  140.   will print `Hello there' as its result.   To include a backslash in a word,
  141.   precede it with another backslash (\\).
  142.  
  143.        Numbers.  A number is a special case of a word, in which  the  charac-
  144.   ters  are  all  digits.  (That definition isn't quite complete, and will be
  145.   expanded in the next paragraph.)  A number need not be preceded with a quo-
  146.   tation mark.  (This rule is possible because normally Logo interprets words
  147.   without quotation marks as the names of procedures, but there are  no  pro-
  148.   cedures whose names are all digits.)
  149.  
  150.        Actually, numbers may be written in  scientific  notation.   That  is,
  151.   they  can  include  signs,  decimal  points, and a power of 10 by which the
  152.   number is multiplied.  This exponent is indicated by the letter e  followed
  153.   by the integer power of 10.  The following numbers have the same value:
  154.  
  155.        1000
  156.        "1000
  157.        1000.00
  158.        1e3
  159.        10.0E+2
  160.        "+1.0e3
  161.        10000E-1
  162.  
  163.   A number  which contains  only digits  (no decimal  point  or exponent)  is
  164.   called an integer.
  165.  
  166.        Since a number is a word, the usual character-manipulating  procedures
  167.   may be applied to it.  For example,
  168.  
  169.        print first 1024
  170.  
  171.   prints the digit 1 which is the first character of the  number.   In  addi-
  172.   tion, there are arithmetic procedures which apply specifically to numbers:
  173.  
  174.        print sum 3 2
  175.  
  176.   prints the number 5.  These procedures will be listed later.
  177.  
  178.        Lists.  A word can be thought of as a list of characters; for example,
  179.   the  word hello is a list of five letters.  In Logo it is possible to mani-
  180.   pulate not only lists of characters but also lists of words, lists of lists
  181.   of  words, and so on.  This is a very powerful capability which allows very
  182.   complicated data structures to be manipulated easily.  To indicate  a  list
  183.   in  a  program,  you  put  square  brackets  ([ and ]) around the list, and
  184.   separate the list elements with spaces.  For example:
  185.  
  186.        print [ This is a list of seven words. ]
  187.  
  188.   A list all of whose elements are words is called a sentence.   Here  is  an
  189.   example of a list which is not a sentence:
  190.  
  191.        print [ [ This is a list ] [ of two sentences. ] ]
  192.  
  193.        Within a bracketed list,  square  brackets  delimit  sub-lists  (lists
  194.   which are elements of the main list).  The quotation mark, parentheses, and
  195.   braces are not considered special within a bracketed list, unlike the rules
  196.   for  quoted  words.  A list may extend over more than one line; that is, if
  197.   you have typed an open square bracket ([) and have not yet typed the match-
  198.   ing  close  square bracket, the Logo instruction is not ended by typing the
  199.   RETURN key.
  200.  
  201.        Variables.  A variable is an entity which has a name, which is a word,
  202.   and a thing (also called a value), which can be any Logo object.  Variables
  203.   are used to "remember" a computed object for repeated or delayed use  in  a
  204.   program.   In Logo, the most common way that a variable acquires a value is
  205.   that it is associated with an input to a user-written  procedure.   In  the
  206.   following  example, don't worry about the details of the format of the pro-
  207.   cedure, which will be explained later:
  208.  
  209.        to pff :in.sentence
  210.           print first first :in.sentence
  211.        end
  212.  
  213.   This is the definition of a command with one input.  The name of  the  com-
  214.   mand  is pff.   It has one input following the  procedure  name  (For  more
  215.   about multiple and optional inputs, check "usermanual.doc".)   The variable
  216.   whose name  is in.sentence is associated with the first (and only,  in this
  217.   case) input to pff.  In the line starting with the word print, the notation
  218.   :in.sentence means "the value of the variable whose name  is  in.sentence".
  219.   (To refer to the name itself, quote it as you would  any  word.)   If  this
  220.   procedure is used in a Logo instruction like this:
  221.  
  222.        pff [ This is the poop. ]
  223.  
  224.   then the variable in-sentence has the value [ This is the poop. ].
  225.  
  226.        It is also possible to assign a value to a  variable  by  an  explicit
  227.   Logo instruction.  There is a primitive procedure to do this:
  228.  
  229.   make - Command, two inputs.
  230.        The first input is the name of a variable  (that  is,  it  must  be  a
  231.        word); the second is any Logo object.  The effect of the command is to
  232.        assign the second input as the value of  the  variable  named  by  the
  233.        first input.
  234.  
  235.        Ifyou are accustomed to programming  in a non-procedural language like
  236.   BASIC,  you should strenuously avoid the temptation to overuse make; expli-
  237.   cit assignment is almost always the wrong  thing  to  do  in  Logo.   Total
  238.   abstention is the best policy for a Logo beginner.
  239.  
  240.        In Logo, variables are dynamically scoped.  That means that a variable
  241.   can "belong to" a particular procedure; such a variable can be used by that
  242.   procedure and by any procedure which is used by an instruction  within  the
  243.   procedure,  but  is not available to the procedure which invoked the owning
  244.   procedure.  In other words, such a local variable comes into being when the
  245.   owning procedure starts running, and disappears when that procedure is fin-
  246.   ished.  It is possible for a procedure with a local variable to use another
  247.   procedure  with a local variable of the same name.  In that case, the vari-
  248.   able belonging to the "inner" procedure is the one which is associated with
  249.   the  name  as  long as it exists; when the inner procedure is finished, the
  250.   "hidden" variable belonging to the outer procedure is again available.
  251.  
  252.        A variable which is associated with inputs to a procedure is local  to
  253.   that procedure.  Other variables are global: they are  "permanent"  and  do
  254.   not disappear when the procedure in which they  get  their  values  finish.
  255.   See "userman.doc" for details concerning inputs and local variables.
  256.  
  257.        The virtue of local variables is that they make  procedures more inde-
  258.   pendent of one  another than they would  be if global variables  were used.
  259.   In other words, if you use local variables consistently, then nothing  that
  260.   happens  in  one procedure  will change  the  values  of variables  used in
  261.   another procedure.  This makes it very much easier to find program errors.
  262.  
  263.        Primitive_procedures_to_define_user_procedures.   Procedures  can  be
  264.   typed into the Logo interpreter at the question mark prompt,  or loaded in
  265.   from a file.   In either case,  the make command is used to  construct the
  266.   procedure definitions.
  267.  
  268.   to
  269.        This command accepts the name of a procedure to  be  defined, followed
  270.        by the names of inputs.   Then follows one or more lines of  the  Logo
  271.        instructions to be performed when  the  procedure  is  executed.   The
  272.        procedure ends with the word "end".
  273.  
  274.   printout
  275.        The input to this command is a word or a list of words that are proce-
  276.        dure or variable names.   The command prints out a  `to command'  def-
  277.        inition for that name.
  278.  
  279.   erase
  280.        The input to this command is a word or a list of words that are proce-
  281.        dure or variable names.  The command removes the bindings of the input
  282.        names.
  283.  
  284.        Primitive_procedures_to_manipulate_words_and_lists.  There are  primi-
  285.   tive  procedures  to  print text objects on the terminal, to read them from
  286.   the terminal, to combine them into  larger  objects,  to  split  them  into
  287.   smaller objects, and to determine their size and nature:
  288.  
  289.   print
  290.        The input, which may be a word or a list, is printed on the  terminal,
  291.        followed  by  a  new  line character.  (That is, the terminal is posi-
  292.        tioned at the beginning of a new line after printing the object.)   If
  293.        the  object is a list, any sub-lists are delimited by square brackets,
  294.        but the entire object is not delimited by brackets.
  295.  
  296.   type
  297.        The input, which may be a word or a list, is printed on the  terminal,
  298.        without  a  new  line character.  (That is, the terminal remains posi-
  299.        tioned at the end of the object after printing it.)  Brackets are used
  300.        as with the print command.
  301.  
  302.   show
  303.        The input is printed as by the print command, except that if it  is  a
  304.        list  (as  opposed  to a word) it is enclosed in square brackets.
  305.  
  306.   readlist
  307.        Logo waits for a line to be typed by the user.  The  contents  of  the
  308.        line  are  made into a list, as though typed within square brackets as
  309.        part of a Logo instruction.  (The user should not actually type brack-
  310.        ets  around the line, unless s/he desires a list of one element, which
  311.        is a list itself.)  That list is the output from the operation.
  312.  
  313.   word
  314.        The two inputs must be words.  The output is a word which is the  con-
  315.        catenation  of  the two inputs.  There is no space or other separation
  316.        of the two inputs in the output.
  317.  
  318.   sentence
  319.        The two inputs may be words or lists.  The output  is  a  list  formed
  320.        from  the two inputs in this way: if either input is a word, that word
  321.        becomes a member of the output list; if either input is  a  list,  the
  322.        members of that input become members of the output.  Here are some ex-
  323.        amples:
  324.  
  325.             first input         second input        output
  326.             "hello              "test               [ hello test ]
  327.             "goodbye            [ cruel world ]     [ goodbye cruel world ]
  328.             [ a b ]             [ c d ]             [ a b c d ]
  329.             [ ]                 "garply             [ garply ]
  330.  
  331.        If an input is the empty list, as in the last example above,  it  con-
  332.        tributes nothing to the output.
  333.  
  334.   list
  335.        The output is a list of two elements, namely, the two inputs.  The in-
  336.        puts may be words or lists.
  337.  
  338.   fput
  339.        The first input may be any Logo object;
  340.        if the first input is a list, the second must also be a list.
  341.        The  output  is an object which is identical to the second input
  342.        except with the first input at the beginning.
  343.  
  344.   lput
  345.        The first input may be any Logo object;
  346.        if the first input is a list, the second must also be a list.
  347.        The  output  is an object which is identical to the second input
  348.        except with the first input at the end.
  349.  
  350.   first
  351.        The input may be any non-empty Logo object.  If the input is  a  list,
  352.        the output is its first member.  If the input is a word, the output is
  353.        a single-letter word, namely the first letter of the  input.   If  the
  354.        input is empty (a word or list of length zero) an error results.
  355.  
  356.   last
  357.        The input may be any non-empty Logo object.  If the input is  a  list,
  358.        the  output is its last member.  If the input is a word, the output is
  359.        a single-letter word, namely the last letter of the input.  If the in-
  360.        put is empty (a word or list of length zero) an error results.
  361.  
  362.   butfirst
  363.        The input may be any non-empty Logo object.  If the input is  a  list,
  364.        the output is a list equal to the input list with the first member re-
  365.        moved.  (If the input list has only one member, the output is the emp-
  366.        ty  list, a list of zero members.)  If the input is a word, the output
  367.        is a word equal to the input word with the first letter removed.   (If
  368.        the  input is a single-letter word, the output is the empty word.)  If
  369.        the input is empty, an error results.
  370.  
  371.   butlast
  372.        The input may be any non-empty Logo object.  If the input is  a  list,
  373.        the  output is a list equal to the input list with the last member re-
  374.        moved.  (If the input list has only one member, the output is the emp-
  375.        ty  list, a list of zero members.)  If the input is a word, the output
  376.        is a word equal to the input word with the last letter  removed.   (If
  377.        the  input is a single-letter word, the output is the empty word.)  If
  378.        the input is empty, an error results.
  379.  
  380.   count
  381.        The input may be any Logo object.  If the input is a list, the  output
  382.        is a number indicating the number of members in the list.  (Note: only
  383.        top-level members are counted, not members of members.  The  count  of
  384.        the list
  385.  
  386.             [ [ This is ] [ a list ] ]
  387.  
  388.        is 2, not 4.)  If the input is a word, the output  is  the  number  of
  389.        letters  (or  other  characters) in the word.  Remember that in Logo a
  390.        number is just a particular kind of word, so the output from count can
  391.        be manipulated like any other Logo word.
  392.  
  393.   emptyp
  394.        The input can be any Logo object.  The output is the word true if  the
  395.        input  is  of  length  zero  (i.e.,  it is the empty word or the empty
  396.        list).  The output is the word false otherwise.
  397.  
  398.   equalp
  399.        The inputs can be any Logo objects.  The output is the  word  true  if
  400.        the  two inputs are identical.  That is, they must be of the same type
  401.        (both words or both lists), they must have the same count,  and  their
  402.        members  (if  lists) or their characters (if words) must be identical.
  403.        The output is the word false otherwise.
  404.  
  405.   wordp
  406.        The input can be any Logo object.  The output is the word true if  the
  407.        input is a word.  The output is the word false if the input is a list.
  408.  
  409.   memberp
  410.        If the second input is a word, the first  input  must  be a  word (and
  411.        only the first letter is used),  and the output is true if and only if
  412.        the first input is contained in the second as  a  character.   If  the
  413.        second  input  is  a list, the first input can be any Logo object, and
  414.        the output is true if and only if the first input is a member  of  the
  415.        second input.  (Note that this is member, not subset.)
  416.  
  417.   item
  418.        The first input must be a positive integer less than or equal  to  the
  419.        count  of the second input.  If the second input is a word, the output
  420.        is a word of length one containing the  selected  character  from  the
  421.        word.   (Items  are numbered from 1, not 0.)  If the second input is a
  422.        list, the output is the selected member of the list.
  423.  
  424.        Primitive_procedures_for_turtles_and_graphics.  An important  part  of
  425.   the  Logo  environment  is a rich set of applications to which the computer
  426.   can be directed.  The most important of these is turtle geometry, a way  of
  427.   describing paths of motion in a plane which is well-suited to computer pro-
  428.   gramming.
  429.  
  430.   forward
  431.        The input is a number, the distance you would like the turtle to move.
  432.        The turtle moves in whatever direction it is pointing when you use the
  433.        command.  Negative inputs make the turtle go backwards.
  434.  
  435.   back
  436.        The input is a number, a distance to move, as in the forward  command.
  437.        The  difference is that the turtle moves backward, i.e., in the direc-
  438.        tion exactly opposite to the way it's pointing.   Negative inputs make
  439.        the turtle go forward.
  440.  
  441.   left
  442.        The input is a number, the number of degrees of  angle  through  which
  443.        the turtle should turn counterclockwise.  This command does not change
  444.        the position of the turtle, but merely its heading (the  direction  in
  445.        which it points).  Negative inputs make the turtle turn right.
  446.  
  447.   right
  448.        The input is a number; the turtle turns through the  specified  number
  449.        of degrees clockwise.  Negative inputs make the turtle turn left.
  450.  
  451.   pu
  452.        This command tells the turtle to raise its pen from the paper, so that
  453.        it does not leave a trace when it moves.   The effect is that any for-
  454.        ward or back commands after this point will not draw a line.  The tur-
  455.        tle starts with its pen down.
  456.  
  457.   pd
  458.        This command tells the turtle to lower its pen, so that later commands
  459.        will draw lines when the turtle moves.
  460.  
  461.   clean
  462.        It erases everything in the turtle display window, but does not affect
  463.        the turtle.
  464.  
  465.   seth
  466.        The turtle's heading is set to the input.
  467.  
  468.   toward
  469.        The inputs are the  x and y coordinates  of a point.   The output is a
  470.        number which is the heading to which the turtle must be set, in  order
  471.        to point towards  that point from its  current position.   Note:  this
  472.        operation does not actually move or turn the turtle.   You must use it
  473.        as the input to seth if that is what you want.
  474.  
  475.   heading
  476.        The output is the turtle's current heading.
  477.  
  478.        Primitive_procedures_for_arithmetic.  Several procedures are available
  479.   for  arithmetic  operations  on numbers.  In all cases, the inputs to these
  480.   procedures must be numbers, except as otherwise indicated in the individual
  481.   descriptions.
  482.  
  483.        In general, procedures are used in Logo by typing first  the  name  of
  484.   the  procedure,  then  its  inputs.   This is true of arithmetic procedures
  485.   also, e.g.,
  486.  
  487.        sum 3 2
  488.        quotient 4 2
  489.  
  490.        Logo also supports infix operators, which are placed between  the  two
  491.   numbers to be operated upon:
  492.  
  493.        3 + 2
  494.        4 / 2
  495.  
  496.   sum, +
  497.        The output of this procedure is the sum of the two inputs.
  498.  
  499.   difference, -
  500.        The output of this procedure is the difference of the two inputs.
  501.  
  502.   product, *
  503.        The output of this procedure is the product of the two inputs.
  504.  
  505.   quotient, /
  506.        The output of this procedure is the quotient of the two inputs.
  507.  
  508.   remainder
  509.        The output is the remainder of dividing the first input by the second.
  510.  
  511.   >
  512.        The output of this procedure is the word true if the  first  input  is
  513.        numerically  strictly  greater  than  the second input.  Otherwise the
  514.        output is the word false.
  515.  
  516.   <
  517.        The output of this procedure is the word true if the  first  input  is
  518.        numerically strictly less than the second input.  Otherwise the output
  519.        is the word false.
  520.  
  521.   equalp, =
  522.        The two inputs to this procedure may be any Logo objects.  If they are
  523.        numbers,  then  the  output  is  the word true if they are numerically
  524.        equal, false if they are numerically unequal.  If either input is  not
  525.        a number, then the output is the same as for the procedure: it is true
  526.        if the two inputs are identical, false if not.
  527.  
  528.   numberp
  529.        The input may be any Logo object.  The output is the word true if  the
  530.        input is a number, false if not.
  531.  
  532.   =0
  533.        The input must be a number.  The output is the word true if the  input
  534.        is numerically equal to zero, false otherwise.
  535.  
  536.   random
  537.        The output is a randomly selected integer  between 0 and one less than
  538.        the input.
  539.  
  540.   sqrt
  541.        The input must be a nonnegative number. The output is its square root.
  542.  
  543.   power
  544.        The inputs must be numbers.  If the first is negative, the second must
  545.        be  an integer.  The output is the first number raised to the power of
  546.        the second input.
  547.  
  548.   sin
  549.        The input must be numeric.  The output is the sine of the input.
  550.  
  551.   cos
  552.        The input must be numeric.  The output is the  cosine  of  the  input.
  553.  
  554.   atan
  555.        The input must be numeric.  The output is the arctangent of the input.
  556.  
  557.        Primitive_procedures_for_conditional_execution.  The predicates  (like
  558.   wordp)  which  we've  mentioned above can be used to carry out some command
  559.   only if a condition is met.  The basic command for the purpose is if:
  560.  
  561.   if
  562.        The first input to the if procedure must be either the  word  true  or
  563.        the  word  false.   Typically, it is the output from a predicate.  The
  564.        second and third inputs are lists containing  instruction lines.   The
  565.        second input is executed if the first input is true.   The third input
  566.        is executed if the first input is false:
  567.  
  568.   and
  569.        The two inputs must both be either true or false.  The output is  true
  570.        if both inputs are true; otherwise the output is false.
  571.  
  572.   or
  573.        The two inputs must be either true or false.  The output is true if at
  574.        least one of the inputs is true; otherwise the output is false.
  575.  
  576.   not
  577.        The input must be either true or false.  The output is true if the in-
  578.        put is false, and vice versa.
  579.  
  580.        Primitive_procedures_for_procedure_exit.  A  procedure  written  by  a
  581.   user,  in  Logo,  can be a command or an operation.  If it is an operation,
  582.   you must, in the procedure, say what its output should be.  If it is a com-
  583.   mand, it can simply stop at the end of the procedure, or you can explicitly
  584.   make it stop before the end.
  585.  
  586.   output
  587.        This command is used in a user procedure  which  is  meant  to  be  an
  588.        operation.  The input to this command becomes the output from the user
  589.        procedure.  Please don't be confused by the fact that  the  user  pro-
  590.        cedure is an operation, while the output primitive procedure is a com-
  591.        mand used in that procedure.  Example:
  592.  
  593.        to nickname :person
  594.           if equalp :person [ Peter Parker ] [ output "Spiderman ]
  595.           if equalp :person [ Lamont Cranston ] [ output "Shadow ]
  596.           output first :person
  597.        end
  598.  
  599.   stop
  600.        This command is used in user procedures which are  meant  to  be  com-
  601.        mands.   It stops the user procedure.  (Note that it does not stop all
  602.        running procedures.  If user procedure A runs user procedure B, a stop
  603.        command  in  procedure B returns to procedure A, which continues after
  604.        the point where procedure B was invoked.)
  605.  
  606.   toplevel
  607.        This command stops all running procedures.  The user at  the  terminal
  608.        is  prompted  to  type  another command.  This can be used when a user
  609.        procedure discovers some error condition and wants to abort the entire
  610.        program, for example.
  611.  
  612.        Property_lists.  It is possible to associate with any name a  list  of
  613.   "properties".  A property list contains property names and property values.
  614.   For example:
  615.  
  616.        putprop "bh "firstname "Brian
  617.        putprop "bh "lastname "Harvey
  618.  
  619.   The form of a property list is
  620.  
  621.        [ name1 val1 name2 val2 name3 val3 ]
  622.  
  623.   Although this data structure could be created using other Logo  primitives,
  624.   special property list primitives are provided because they are faster.  The
  625.   following primitives manipulate property lists.
  626.  
  627.   putprop
  628.        The first input, which must be a word, is a name with which a property
  629.        list  is  associated.   The second input, which must be a word, is the
  630.        name of a property.  The third input can be any Logo object.   It  be-
  631.        comes the value of the specified property of the specified name.
  632.  
  633.   getprop
  634.        Both inputs must be words.  The first is a name, and the second  is  a
  635.        property  name.   The output is the value of the indicated property of
  636.        the indicated object.  It is not an error if there is no such  proper-
  637.        ty; the output in that case is the empty list.
  638.  
  639.   remprop - Command, two inputs.
  640.        The inputs must be words, as for gprop.  The specified property is re-
  641.        moved from the specified name.
  642.  
  643.        Pausing.  When you are debugging a complicated  Logo  program,  it  is
  644.   very  helpful  to be able to stop in the middle of a procedure, so that you
  645.   can give interactive commands to examine its inputs and other  local  vari-
  646.   ables.  This is different from stopping a procedure, which destroys its lo-
  647.   cal environment.  There are two ways a procedure can pause: (1) You can use
  648.   the interrupt command (found in the Utilities file) in the procedure defin-
  649.   ition,  to make the procedure pause at a particular place you choose in ad-
  650.   vance;  or (2) you can decide  to pause a procedure  while it is running by
  651.   using the interrupt menu item in the Utilities menu of the command window.
  652.  
  653.        Note that when you type the system "quit"  character (control-G)  Logo
  654.   does not pause,  but returns to toplevel.   All information about the local
  655.   state of your active procedures is lost.
  656.  
  657.        When you are paused, Logo accepts instructions from your  terminal  as
  658.   it  does  at toplevel, but local variables can be examined or modified.  To
  659.   let you know  that you are paused,  Logo prompts with the  characters "-->"
  660.   instead of just "?" as usual.
  661.  
  662.        To get out of a pause, you can give the command toplevel,  which stops
  663.   all pending procedures  and returns  to interactive  top level,  or you can
  664.   give the  command 'stop',  which will resume  the procedure  at the point
  665.   where you paused.
  666.  
  667.   interrupt
  668.        This command  is meaningful  only  within  a procedure.   It causes  a
  669.        pause.
  670.  
  671.        Miscellaneous_primitives.  The remaining primitives are one of a kind,
  672.   or very obscure, or both.
  673.  
  674.   bye
  675.        This command is used to leave Logo.  It is the only  way  out,  unless
  676.        there is a bug somewhere.
  677.  
  678.   thing
  679.        The input must be a  word that is a variable  or procedure name.   The
  680.        output is the value of the variable.  These are equivalent:
  681.  
  682.        :foo
  683.        thing "foo
  684.  
  685.   namep
  686.        The input must be a word.  The output is true if that word is the name
  687.        of a variable which has a value assigned to it, false otherwise.
  688.  
  689.   wait
  690.        The input must be a positive integer.  Logo waits  that  many  seconds
  691.        before continuing.
  692.  
  693.   doscommand
  694.        The input is a list containing a valid CLI command to be executed.
  695.  
  696.   run
  697.        The input must  be a list containing  Logo instructions.   The list is
  698.        run as if you typed  it directly  to Logo.   The run procedure  can be
  699.        used as an operation, if its input is a Logo expression which produces
  700.        a value, instead of a complete instruction:
  701.  
  702.        print run [ sum 2 3 ]
  703.  
  704.   repeat
  705.        The first input must be a positive number.  The second is an  instruc-
  706.        tion  list,  as  for the run command.  The list is run repeatedly, the
  707.        number of times specified by the first input:
  708.  
  709.        repeat 5 [ print "hello ]
  710.  
  711.